﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KL.Store.Core.Domain;
using TN.Data;

namespace KL.Store.Data
{
    public class dbPos
    {
        #region Get

        public static Pos Get(int PosId)
        {
            IList<Pos> objectList = new List<Pos>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Pos_Get", objectList, new object[] { PosId });
            return objectList.FirstOrDefault();
        }

        #endregion

        #region GetList

        public static IList<Pos> GetList()
        {
            IList<Pos> objectList = new List<Pos>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Pos_List", objectList);

            return objectList;
        }

        #endregion

        #region GetListDDL

        public static IList<PosDDL> GetListDDL()
        {
            IList<Pos> objectList = new List<Pos>();
            IList<PosDDL> objectListDDL = new List<PosDDL>();

            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Pos_List", objectList);
            objectListDDL = objectList.Select(o => new PosDDL(o.PosId, o.BankName, o.CardName, o.Description, o.ContractNote, o.Enabled3D, o.Type3D, o.PosVoucher)).ToList<PosDDL>();

            return objectListDDL;
        }

        #endregion

        #region GetInstallmentList

        public static IList<PosInstallment> GetInstallmentList(int PosId, decimal TotalPaymentWithDiscount, decimal TotalPayment, decimal CargoPrice, decimal ListCargoPrice)
        {
            IList<PosInstallment> objectList = new List<PosInstallment>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_PosInstallment_List", objectList, new object[] { PosId, TotalPaymentWithDiscount, TotalPayment, CargoPrice, ListCargoPrice });

            return objectList;
        }

        #endregion

        #region GetInstallmentListPayment

        public static IList<PosInstallment> GetInstallmentListPayment(int PosId, decimal TotalPaymentWithDiscount, decimal TotalPayment, decimal CampaignTotalPaymentWithDiscount, decimal CampaignTotalPayment, decimal CargoPrice, decimal ListCargoPrice)
        {
            IList<PosInstallment> objectList = new List<PosInstallment>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_PosInstallment_List_Payment", objectList, new object[] { PosId, TotalPaymentWithDiscount, TotalPayment, CampaignTotalPaymentWithDiscount, CampaignTotalPayment, CargoPrice, ListCargoPrice });

            return objectList;
        }

        #endregion

        #region GetBinList

        public static IList<PosBin> GetBinList()
        {
            IList<PosBin> objectList = new List<PosBin>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Pos_Bin_List", objectList);

            return objectList;
        }

        #endregion
    }
}
